[Fix] Make channelData optional in ConversationUpdateActivity#243
Draft
rajan-chari wants to merge 1 commit intomainfrom
Draft
[Fix] Make channelData optional in ConversationUpdateActivity#243rajan-chari wants to merge 1 commit intomainfrom
rajan-chari wants to merge 1 commit intomainfrom
Conversation
Make channel_data optional in ConversationUpdateActivity to support Direct Line API 3.0, which sends conversationUpdate activities without channelData field. This fixes validation errors when receiving messages from Direct Line. Changes: - Remove required channel_data field override in ConversationUpdateActivity - Add null checks in activity route selectors before accessing channel_data.event_type - Add comprehensive tests for Direct Line compatibility (8 new tests) - All tests pass (236 total, up from 228) Test Coverage: - ConversationUpdateActivity parsing without channelData (Direct Line scenario) - ConversationUpdateActivity parsing with channelData (Teams scenario) - Activity routing with and without channelData - All event-specific selectors handle None channelData gracefully Fixes #239 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where Direct Line API 3.0 sends conversationUpdate activities without the channelData field, causing validation errors in the Teams SDK for Python. The fix makes channel_data optional in ConversationUpdateActivity and adds null-safety checks to activity route selectors.
Changes:
- Made
channel_dataoptional inConversationUpdateActivityby removing the required field override - Added null checks to 13 activity route selectors before accessing
event_typeproperty - Added comprehensive test coverage with 8 new tests for Direct Line compatibility
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/api/src/microsoft_teams/api/activities/conversation/conversation_update.py | Removed required override for channel_data, making it optional by inheriting from base class |
| packages/apps/src/microsoft_teams/apps/routing/activity_route_configs.py | Added null checks to selectors for message and conversation event types to prevent AttributeError |
| packages/api/tests/unit/test_conversation_update_directline.py | New test file with 3 tests verifying Direct Line compatibility and parsing behavior |
| packages/apps/tests/test_conversation_update_routing.py | New test file with 5 tests verifying routing behavior with and without channel_data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #239
Summary
Make
channel_dataoptional inConversationUpdateActivityto support Direct Line API 3.0, which sendsconversationUpdateactivities without thechannelDatafield. This fixes validation errors when receiving messages from Direct Line.Problem
When using Direct Line API 3.0 with the Teams SDK for Python, Direct Line automatically sends
conversationUpdateactivities withoutchannelDatawhen starting a conversation. The Teams SDK required this field, causing Pydantic validation errors:Changes
channel_dataoptional inConversationUpdateActivity- Removed the required field override, allowing it to inherit the optional definition from the base classactivity.channel_data is not None) before accessingevent_typein 13 selectors to prevent AttributeErrorTest Results
Files Changed
packages/api/src/microsoft_teams/api/activities/conversation/conversation_update.pypackages/apps/src/microsoft_teams/apps/routing/activity_route_configs.pypackages/api/tests/unit/test_conversation_update_directline.py(new)packages/apps/tests/test_conversation_update_routing.py(new)🤖 Generated with Claude Code